$(function(){
	var head=localStorage.getItem("head");
	var name=localStorage.getItem("name");
	var identity=localStorage.getItem("identity");
	var signOut=localStorage.getItem("signOut");
	var navigation=$("#navigation div");
	navigation.empty();
	if(head&&signOut==0){
		navigation.append(
			"<img class='head' src="+head+">"+
			"<button class='btn btn-info'>"+name+"</button>"+
			"<button class='btn btn-info' onclick='signOut()'>"+"退出"+"</button>"
		);
		if(identity=="admin"){
			navigation.append("<button class='btn btn-info' onclick='amAdmin()'>"+"控制台"+"</button>")
		};
	}else{
		navigation.append(
			"<button id='logOn' class='btn btn-info'>"+"登录"+"</button>"+
			"<button id='register' class='btn btn-info'>"+"注册"+"</button>"
		);
	}
});

$(function(){
	var id=window.location.search.replace(/\?/g,"")
	console.log("location:"+id);
	$.ajax({
		type:"POST",
		url:"http://localhost:3000/server/target",
		dataType:"json",
		data:{
			num:id
		},
	  	success:function(x,y,z){
	  		$("#movie").append("<div>"+
			"<div class='img'><img src="+x[0].poster+"></div>"+
			"<div>片名:"+x[0].title+"</div>"+
			"<div>导演:"+x[0].doctor+"</div>"+
			"<div>国家:"+x[0].country+"</div>"+
			"<div>语言:"+x[0].language+"</div>"+
			"<div>年代:"+x[0].year+"</div>"+	
			"<div>")
	  	},
	  	error:function(jqXHR){
			console.log(jqXHR);
	  	}
	})
});

function signOut(){
	localStorage.setItem("signOut",1);
	window.location.href="http://localhost:3000";
}